<?php

declare(strict_types=1);

namespace App\Api\Controller;

use App\Api\Middleware\ApiLockMiddleware;
use App\Api\Middleware\ResponseMiddleware;
use App\Api\Request\AuthRequest;
use App\Api\Service\AuthService;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middlewares;
use Hyperf\HttpServer\Annotation\PostMapping;

#[Controller(prefix: 'api'), Middlewares([ResponseMiddleware::class])]
class AuthController
{
    /**
     * 登录
     * @param AuthRequest $request
     * @param AuthService $service
     * @return array
     */
    #[PostMapping('auth/login'), Middlewares([ApiLockMiddleware::class])]
    public function login(AuthRequest $request, AuthService $service): array
    {
        return $service->login($request->validated());
    }
}
